cmake_minimum_required(VERSION 3.12)

project(ds LANGUAGES C CXX)

set(BUILD_SHARED_LIBS OFF)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE	ON)

list(APPEND _sources network.c
    convolutional_layer.c
    connected_layer.c
    maxpool_layer.c
    softmax_layer.c
    input_layer.c
    layer.c
    blas.c
    im2col.c
    activations.c
    minst_data_set.c
    image.c
    matrix.c
    data.c
    gemm.c)

add_library(dsnet-objs OBJECT ${_sources})
set_target_properties(dsnet-objs 
    PROPERTIES 
    POSITION_INDEPENDENT_CODE 1
    C_STANDARD 99
    C_EXTENSIONS OFF
    C_STANDARD_REQUIRED ON)

add_library(dsnet-static STATIC $<TARGET_OBJECTS:dsnet-objs>)
set_target_properties(dsnet-static PROPERTIES OUTPUT_NAME "dsnet")
target_link_libraries(dsnet-static m)

if (BUILD_SHARED_LIBS)
    add_library(dsnet-shared SHARED $<TARGET_OBJECTS:dsnet-objs>)
    set_target_properties(dsnet-shared PROPERTIES OUTPUT_NAME "dsnet")
    target_link_libraries(dsnet-shared m)
endif()
